package dbcloud;

public class Grid {
	
	private int titleX;
	private int titleY;
	private int zoom;
	
	
	public Grid(int x, int y, int z)
	{
		titleX = x;
		titleY = y;
		zoom = z;
	}
	
	public Grid toHighGrid(int _zoom)
	{
		assert(zoom < _zoom);
		int i = zoom - _zoom;
		if(i == 0)
			return new Grid(titleX, titleY, _zoom);
		return new Grid(titleX >> i, titleY >> i, _zoom);
	}
	
	public int getTitleX() {
		return titleX;
	}
	public void setTitleX(int titleX) {
		this.titleX = titleX;
	}
	public int getTitleY() {
		return titleY;
	}
	public void setTitleY(int titleY) {
		this.titleY = titleY;
	}
	public int getZoom() {
		return zoom;
	}
	public void setZoom(int zoom) {
		this.zoom = zoom;
	}
	
	public int hashCode() {
		return titleX + titleY << 16 + zoom << 24;
	}
	
	public boolean equals(Object o) {
		return (titleX == ((Grid) o).titleX)
			&& (titleY == ((Grid) o).titleY)
			&& (zoom == ((Grid) o).zoom);
	}

}
